package com.chi.thread.thread;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 实现runnable实现接口，AtomicInteger使用自旋锁进行compareAndSet
 * @author chi  2017-06-22 21:48
 **/
public class MyRunnable implements Runnable{
    private static AtomicInteger atomicInteger = new AtomicInteger(0);

    public void run() {
        int i = atomicInteger.incrementAndGet();
    }

    public static void main(String[] args){
        for (int i = 1; i<100; i++){
            MyRunnable myRunnable = new MyRunnable();
            new Thread(myRunnable).start();
        }
    }
}
